<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
session_start();  
if(isset($_SESSION['username'])){  
    //返回之前的页面  
}  
?>
      
    <!DOCTYPE html PUBLIC "-//W3C//Ddiv XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Ddiv/xhtml1-transitional.ddiv">  
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
      
      
    <!-- <script src="../lib/jquery/jquery.md5.js" type="text/javascript"></script>   -->
    <script src="http://c.csdnimg.cn/public/common/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>  
    <!-- <script src="login.js" type="text/javascript"></script>   -->
      
    <title>登录</title>  
    </head>  
    <div class="container">  
                <div>  
                    <img src="../images/logo.png" alt="logo" width="705px"></img>  
                    <hr>  
                </div>  
                  
                <form method="post" action="">  
                <div>  
                    <div>  
                        <div>  
                            <input class='loginusername' type="text" name="username" placeholder="用户名" onfocus="this.placeholder=''" onblur="this.placeholder='用户名'">  
                        </div>  
                        <div>  
                            <input class='loginpassword' type="password" name="password" placeholder="密码" onfocus="this.placeholder=''" onblur="this.placeholder='密码'">  
                        </div>  
                        <div>  
                            <input class='loginsubmit' type="submit" value="登录">  
                        </div>  
                        <div></div>  
                    </div>  
                </div>  
                </form>  
                  
                <div>  
                    <hr>  
                    版权信息  
                </div>  
    </div>  
  <script type="text/javascript">
  	$(function(){  
  $("form").submit(function(e){  
      var username = $(".loginusername").val();  
      var password = $(".loginpassword").val();  
      var act = 'ad'; 
      
      if(username!='' && password!=''){     
          var errormessage = "用户名密码匹配中……";  
          $.ajax({
              data:{pid:username,limt:password},       //要发送的数据  
              type:"POST",           //发送的方式  
              url:"home/index.php/Index_Home/index", //url地址  
              error:function(msg){ //处理出错的信息  
                  var errormessage="再试一次";
                  $(".loginerror").html(errormessage);  
              },  
              success:function(msg){  //处理正确时的信息  
                  alert("success" + msg)  
                  if(msg!=''){  
                      var errormessage="登录成功";  
                      $(".loginerror").html(errormessage);  
                        
                      location.href = "http://localhost/"  
                  }else{  
                      var errormessage="用户名或密码错误";  
                      $(".loginerror").html(errormessage);  
                  }  
              }  
          });  
            
      }else{  
         var errormessage = "用户名或密码不能为空";  
      }  
        
      $(".loginerror").html(errormessage);    
      return false;  
  });  
});  

  </script>    
      
    </html>  